home *** CD-ROM | disk | FTP | other *** search
/ Download Now 8 / Download Now V8.iso / Program / InternetTools / CoffeeCupHTMLeditor / CoffeeHTML82.exe / %MAINDIR% / cgi-bin / formmail / FormMail.pl next >
Encoding:
Perl Script  |  2000-05-08  |  24.7 KB  |  642 lines

  1. #!/usr/bin/perl
  2. ##############################################################################
  3. # FormMail                        Version 1.6                                #
  4. # Copyright 1995-1997 Matt Wright mattw@worldwidemart.com                    #
  5. # Created 06/09/95                Last Modified 05/02/97                     #
  6. # Matt's Script Archive, Inc.:    http://www.worldwidemart.com/scripts/      #
  7. ##############################################################################
  8. #         SEE README.TXT FILE THAT CAME WITH THIS SCRIPT FOR HELP            #
  9. #   OR: Consult the Matt's Script Archive Frequently Asked Questions if you  #
  10. #   are having any problems:                                                 #
  11. #   http://www.worldwidemart.com/scripts/faq/                                #
  12. ##############################################################################
  13. # COPYRIGHT NOTICE                                                           #
  14. # Copyright 1995-1997 Matthew M. Wright  All Rights Reserved.                #
  15. #                                                                            #
  16. # FormMail may be used and modified free of charge by anyone so long as this #
  17. # copyright notice and the comments above remain intact.  By using this      #
  18. # code you agree to indemnify Matthew M. Wright and CoffeeCup Software from  #
  19. # any liability that might arise from its use.                               #
  20. #                                                                            #
  21. # Selling the code for this program without prior written consent is         #
  22. # expressly forbidden.  In other words, please ask first before you try and  #
  23. # make money off of my program.                                              #
  24. #                                                                            #
  25. # Obtain permission before redistributing this software over the Internet or #
  26. # in any other medium.  In all cases copyright and header must remain intact #
  27. ##############################################################################
  28. # Define Variables                                                           #
  29. #     Detailed Information Found In README File.                           #
  30.  
  31. # $mailprog defines the location of your sendmail program on your unix       #
  32. # system.                                                                    #
  33.  
  34. $mailprog = '/usr/lib/sendmail';
  35.  
  36. # @referers allows forms to be located only on servers which are defined     #
  37. # in this field.  This security fix from the last version which allowed      #
  38. # anyone on any server to use your FormMail script on their web site.        #
  39.  
  40. @referers = ('worldwidemart.com','206.31.72.203');
  41.  
  42. # Done                                                                       #
  43. ##############################################################################
  44.  
  45. # Check Referring URL
  46. &check_url;
  47.  
  48. # Retrieve Date
  49. &get_date;
  50.  
  51. # Parse Form Contents
  52. &parse_form;
  53.  
  54. # Check Required Fields
  55. &check_required;
  56.  
  57. # Return HTML Page or Redirect User
  58. &return_html;
  59.  
  60. # Send E-Mail
  61. &send_mail;
  62.  
  63. sub check_url {
  64.  
  65.     # Localize the check_referer flag which determines if user is valid.     #
  66.     local($check_referer) = 0;
  67.  
  68.     # If a referring URL was specified, for each valid referer, make sure    #
  69.     # that a valid referring URL was passed to FormMail.                     #
  70.  
  71.     if ($ENV{'HTTP_REFERER'}) {
  72.         foreach $referer (@referers) {
  73.             if ($ENV{'HTTP_REFERER'} =~ m|https?://([^/]*)$referer|i) {
  74.                 $check_referer = 1;
  75.                 last;
  76.             }
  77.         }
  78.     }
  79.     else {
  80.         $check_referer = 1;
  81.     }
  82.  
  83.     # If the HTTP_REFERER was invalid, send back an error.                   #
  84.     if ($check_referer != 1) { &error('bad_referer') }
  85. }
  86.  
  87. sub get_date {
  88.  
  89.     # Define arrays for the day of the week and month of the year.           #
  90.     @days   = ('Sunday','Monday','Tuesday','Wednesday',
  91.                'Thursday','Friday','Saturday');
  92.     @months = ('January','February','March','April','May','June','July',
  93.              'August','September','October','November','December');
  94.  
  95.     # Get the current time and format the hour, minutes and seconds.  Add    #
  96.     # 1900 to the year to get the full 4 digit year.                         #
  97.     ($sec,$min,$hour,$mday,$mon,$year,$wday) = (localtime(time))[0,1,2,3,4,5,6];
  98.     $time = sprintf("%02d:%02d:%02d",$hour,$min,$sec);
  99.     $year += 1900;
  100.  
  101.     # Format the date.                                                       #
  102.     $date = "$days[$wday], $months[$mon] $mday, $year at $time";
  103.  
  104. }
  105.  
  106. sub parse_form {
  107.  
  108.     # Define the configuration associative array.                            #
  109.     %Config = ('recipient','',          'subject','',
  110.                'email','',              'realname','',
  111.                'redirect','',           'bgcolor','',
  112.                'background','',         'link_color','',
  113.                'vlink_color','',        'text_color','',
  114.                'alink_color','',        'title','',
  115.                'sort','',               'print_config','',
  116.                'required','',           'env_report','',
  117.                'return_link_title','',  'return_link_url','',
  118.                'print_blank_fields','', 'missing_fields_redirect','');
  119.  
  120.     # Determine the form's REQUEST_METHOD (GET or POST) and split the form   #
  121.     # fields up into their name-value pairs.  If the REQUEST_METHOD was      #
  122.     # not GET or POST, send an error.                                        #
  123.     if ($ENV{'REQUEST_METHOD'} eq 'GET') {
  124.         # Split the name-value pairs
  125.         @pairs = split(/&/, $ENV{'QUERY_STRING'});
  126.     }
  127.     elsif ($ENV{'REQUEST_METHOD'} eq 'POST') {
  128.         # Get the input
  129.         read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
  130.  
  131.         # Split the name-value pairs
  132.         @pairs = split(/&/, $buffer);
  133.     }
  134.     else {
  135.         &error('request_method');
  136.     }
  137.  
  138.     # For each name-value pair:                                              #
  139.     foreach $pair (@pairs) {
  140.  
  141.         # Split the pair up into individual variables.                       #
  142.         local($name, $value) = split(/=/, $pair);
  143.  
  144.         # Decode the form encoding on the name and value variables.          #
  145.         $name =~ tr/+/ /;
  146.         $name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
  147.  
  148.         $value =~ tr/+/ /;
  149.         $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
  150.  
  151.         # If they try to include server side includes, erase them, so they
  152.         # aren't a security risk if the html gets returned.  Another 
  153.         # security hole plugged up.
  154.         $value =~ s/<!--(.|\n)*-->//g;
  155.  
  156.         # If the field name has been specified in the %Config array, it will #
  157.         # return a 1 for defined($Config{$name}}) and we should associate    #
  158.         # this value with the appropriate configuration variable.  If this   #
  159.         # is not a configuration form field, put it into the associative     #
  160.         # array %Form, appending the value with a ', ' if there is already a #
  161.         # value present.  We also save the order of the form fields in the   #
  162.         # @Field_Order array so we can use this order for the generic sort.  #
  163.         if (defined($Config{$name})) {
  164.             $Config{$name} = $value;
  165.         }
  166.         else {
  167.             if ($Form{$name} && $value) {
  168.                 $Form{$name} = "$Form{$name}, $value";
  169.             }
  170.             elsif ($value) {
  171.                 push(@Field_Order,$name);
  172.                 $Form{$name} = $value;
  173.             }
  174.         }
  175.     }
  176.  
  177.     # The next six lines remove any extra spaces or new lines from the       #
  178.     # configuration variables, which may have been caused if your editor     #
  179.     # wraps lines after a certain length or if you used spaces between field #
  180.     # names or environment variables.                                        #
  181.     $Config{'required'} =~ s/(\s+|\n)?,(\s+|\n)?/,/g;
  182.     $Config{'required'} =~ s/(\s+)?\n+(\s+)?//g;
  183.     $Config{'env_report'} =~ s/(\s+|\n)?,(\s+|\n)?/,/g;
  184.     $Config{'env_report'} =~ s/(\s+)?\n+(\s+)?//g;
  185.     $Config{'print_config'} =~ s/(\s+|\n)?,(\s+|\n)?/,/g;
  186.     $Config{'print_config'} =~ s/(\s+)?\n+(\s+)?//g;
  187.  
  188.     # Split the configuration variables into individual field names.         #
  189.     @Required = split(/,/,$Config{'required'});
  190.     @Env_Report = split(/,/,$Config{'env_report'});
  191.     @Print_Config = split(/,/,$Config{'print_config'});
  192. }
  193.  
  194. sub check_required {
  195.  
  196.     # Localize the variables used in this subroutine.                        #
  197.     local($require, @error);
  198.  
  199.     if (!$Config{'recipient'}) {
  200.         if (!defined(%Form)) { &error('bad_referer') }
  201.         else                 { &error('no_recipient') }
  202.     }
  203.  
  204.     # For each require field defined in the form:                            #
  205.     foreach $require (@Required) {
  206.  
  207.         # If the required field is the email field, the syntax of the email  #
  208.         # address if checked to make sure it passes a valid syntax.          #
  209.         if ($require eq 'email' && !&check_email($Config{$require})) {
  210.             push(@error,$require);
  211.         }
  212.  
  213.         # Otherwise, if the required field is a configuration field and it   #
  214.         # has no value or has been filled in with a space, send an error.    #
  215.         elsif (defined($Config{$require})) {
  216.             if (!$Config{$require}) {
  217.                 push(@error,$require);
  218.             }
  219.         }
  220.  
  221.         # If it is a regular form field which has not been filled in or      #
  222.         # filled in with a space, flag it as an error field.                 #
  223.         elsif (!$Form{$require}) {
  224.             push(@error,$require);
  225.         }
  226.     }
  227.  
  228.     # If any error fields have been found, send error message to the user.   #
  229.     if (@error) { &error('missing_fields', @error) }
  230. }
  231.  
  232. sub return_html {
  233.     # Local variables used in this subroutine initialized.                   #
  234.     local($key,$sort_order,$sorted_field);
  235.  
  236.     # If redirect option is used, print the redirectional location header.   #
  237.     if ($Config{'redirect'}) {
  238.         print "Location: $Config{'redirect'}\n\n";
  239.     }
  240.  
  241.     # Otherwise, begin printing the response page.                           #
  242.     else {
  243.  
  244.         # Print HTTP header and opening HTML tags.                           #
  245.         print "Content-type: text/html\n\n";
  246.         print "<html>\n <head>\n";
  247.  
  248.         # Print out title of page                                            #
  249.         if ($Config{'title'}) { print "  <title>$Config{'title'}</title>\n" }
  250.         else                  { print "  <title>Thank You</title>\n"        }
  251.  
  252.         print " </head>\n <body";
  253.  
  254.         # Get Body Tag Attributes                                            #
  255.         &body_attributes;
  256.  
  257.         # Close Body Tag                                                     #
  258.         print ">\n  <center>\n";
  259.  
  260.         # Print custom or generic title.                                     #
  261.         if ($Config{'title'}) { print "   <h1>$Config{'title'}</h1>\n" }
  262.         else { print "   <h1>Thank You For Filling Out This Form</h1>\n" }
  263.  
  264.         print "</center>\n";
  265.  
  266.         print "Below is what you submitted to $Config{'recipient'} on ";
  267.         print "$date<p><hr size=1 width=75\%><p>\n";
  268.  
  269.         # Sort alphabetically if specified:                                  #
  270.         if ($Config{'sort'} eq 'alphabetic') {
  271.             foreach $field (sort keys %Form) {
  272.  
  273.                 # If the field has a value or the print blank fields option  #
  274.                 # is turned on, print out the form field and value.          #
  275.                 if ($Config{'print_blank_fields'} || $Form{$field}) {
  276.                     print "<b>$field:</b> $Form{$field}<p>\n";
  277.                 }
  278.             }
  279.         }
  280.  
  281.         # If a sort order is specified, sort the form fields based on that.  #
  282.         elsif ($Config{'sort'} =~ /^order:.*,.*/) {
  283.  
  284.             # Set the temporary $sort_order variable to the sorting order,   #
  285.             # remove extraneous line breaks and spaces, remove the order:    #
  286.             # directive and split the sort fields into an array.             #
  287.             $sort_order = $Config{'sort'};
  288.             $sort_order =~ s/(\s+|\n)?,(\s+|\n)?/,/g;
  289.             $sort_order =~ s/(\s+)?\n+(\s+)?//g;
  290.             $sort_order =~ s/order://;
  291.             @sorted_fields = split(/,/, $sort_order);
  292.  
  293.             # For each sorted field, if it has a value or the print blank    #
  294.             # fields option is turned on print the form field and value.     #
  295.             foreach $sorted_field (@sorted_fields) {
  296.                 if ($Config{'print_blank_fields'} || $Form{$sorted_field}) {
  297.                     print "<b>$sorted_field:</b> $Form{$sorted_field}<p>\n";
  298.                 }
  299.             }
  300.         }
  301.  
  302.         # Otherwise, default to the order in which the fields were sent.     #
  303.         else {
  304.  
  305.             # For each form field, if it has a value or the print blank      #
  306.             # fields option is turned on print the form field and value.     #
  307.             foreach $field (@Field_Order) {
  308.                 if ($Config{'print_blank_fields'} || $Form{$field}) {
  309.                     print "<b>$field:</b> $Form{$field}<p>\n";
  310.                 }
  311.             }
  312.         }
  313.  
  314.         print "<p><hr size=1 width=75%><p>\n";
  315.  
  316.         # Check for a Return Link and print one if found.                    #
  317.         if ($Config{'return_link_url'} && $Config{'return_link_title'}) {
  318.             print "<ul>\n";
  319.             print "<li><a href=\"$Config{'return_link_url'}\">$Config{'return_link_title'}</a>\n";
  320.             print "</ul>\n";
  321.         }
  322.  
  323.         # Print the page footer.                                             #
  324.         print <<"(END HTML FOOTER)";
  325.         <hr size=1 width=75%><p> 
  326.         <center><font size=-1><a href="http://www.worldwidemart.com/scripts/formmail.shtml">FormMail</a> V1.6 © 1995 -1997  Matt Wright<br>
  327. A Free Product of <a href="http://www.worldwidemart.com/scripts/">Matt's Script Archive, Inc.</a></font></center>
  328.         </body>
  329.        </html>
  330. (END HTML FOOTER)
  331.     }
  332. }
  333.  
  334. sub send_mail {
  335.     # Localize variables used in this subroutine.                            #
  336.     local($print_config,$key,$sort_order,$sorted_field,$env_report);
  337.  
  338.     # Open The Mail Program
  339.     open(MAIL,"|$mailprog -t");
  340.  
  341.     print MAIL "To: $Config{'recipient'}\n";
  342.     print MAIL "From: $Config{'email'} ($Config{'realname'})\n";
  343.  
  344.     # Check for Message Subject
  345.     if ($Config{'subject'}) { print MAIL "Subject: $Config{'subject'}\n\n" }
  346.     else                    { print MAIL "Subject: WWW Form Submission\n\n" }
  347.  
  348.     print MAIL "Below is the result of your feedback form.  It was submitted by\n";
  349.     print MAIL "$Config{'realname'} ($Config{'email'}) on $date\n";
  350.     print MAIL "-" x 75 . "\n\n";
  351.  
  352.     if (@Print_Config) {
  353.         foreach $print_config (@Print_Config) {
  354.             if ($Config{$print_config}) {
  355.                 print MAIL "$print_config: $Config{$print_config}\n\n";
  356.             }
  357.         }
  358.     }
  359.  
  360.     # Sort alphabetically if specified:                                      #
  361.     if ($Config{'sort'} eq 'alphabetic') {
  362.         foreach $field (sort keys %Form) {
  363.  
  364.             # If the field has a value or the print blank fields option      #
  365.             # is turned on, print out the form field and value.              #
  366.             if ($Config{'print_blank_fields'} || $Form{$field} ||
  367.                 $Form{$field} eq '0') {
  368.                 print MAIL "$field: $Form{$field}\n\n";
  369.             }
  370.         }
  371.     }
  372.  
  373.     # If a sort order is specified, sort the form fields based on that.      #
  374.     elsif ($Config{'sort'} =~ /^order:.*,.*/) {
  375.  
  376.         # Remove extraneous line breaks and spaces, remove the order:        #
  377.         # directive and split the sort fields into an array.                 #
  378.         $Config{'sort'} =~ s/(\s+|\n)?,(\s+|\n)?/,/g;
  379.         $Config{'sort'} =~ s/(\s+)?\n+(\s+)?//g;
  380.         $Config{'sort'} =~ s/order://;
  381.         @sorted_fields = split(/,/, $Config{'sort'});
  382.  
  383.         # For each sorted field, if it has a value or the print blank        #
  384.         # fields option is turned on print the form field and value.         #
  385.         foreach $sorted_field (@sorted_fields) {
  386.             if ($Config{'print_blank_fields'} || $Form{$sorted_field} ||
  387.                 $Form{$sorted_field} eq '0') {
  388.                 print MAIL "$sorted_field: $Form{$sorted_field}\n\n";
  389.             }
  390.         }
  391.     }
  392.  
  393.     # Otherwise, default to the order in which the fields were sent.         #
  394.     else {
  395.  
  396.         # For each form field, if it has a value or the print blank          #
  397.         # fields option is turned on print the form field and value.         #
  398.         foreach $field (@Field_Order) {
  399.             if ($Config{'print_blank_fields'} || $Form{$field} ||
  400.                 $Form{$field} eq '0') {
  401.                 print MAIL "$field: $Form{$field}\n\n";
  402.             }
  403.         }
  404.     }
  405.  
  406.     print MAIL "-" x 75 . "\n\n";
  407.  
  408.     # Send any specified Environment Variables to recipient.                 #
  409.     foreach $env_report (@Env_Report) {
  410.         if ($ENV{$env_report}) {
  411.             print MAIL "$env_report: $ENV{$env_report}\n";
  412.         }
  413.     }
  414.  
  415.     close (MAIL);
  416. }
  417.  
  418. sub check_email {
  419.     # Initialize local email variable with input to subroutine.              #
  420.     $email = $_[0];
  421.  
  422.     # If the e-mail address contains:                                        #
  423.     if ($email =~ /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/ ||
  424.  
  425.         # the e-mail address contains an invalid syntax.  Or, if the         #
  426.         # syntax does not match the following regular expression pattern     #
  427.         # it fails basic syntax verification.                                #
  428.  
  429.         $email !~ /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/) {
  430.  
  431.         # Basic syntax requires:  one or more characters before the @ sign,  #
  432.         # followed by an optional '[', then any number of letters, numbers,  #
  433.         # dashes or periods (valid domain/IP characters) ending in a period  #
  434.         # and then 2 or 3 letters (for domain suffixes) or 1 to 3 numbers    #
  435.         # (for IP addresses).  An ending bracket is also allowed as it is    #
  436.         # valid syntax to have an email address like: user@[255.255.255.0]   #
  437.  
  438.         # Return a false value, since the e-mail address did not pass valid  #
  439.         # syntax.                                                            #
  440.         return 0;
  441.     }
  442.  
  443.     else {
  444.  
  445.         # Return a true value, e-mail verification passed.                   #
  446.         return 1;
  447.     }
  448. }
  449.  
  450. sub body_attributes {
  451.     # Check for Background Color
  452.     if ($Config{'bgcolor'}) { print " bgcolor=\"$Config{'bgcolor'}\"" }
  453.  
  454.     # Check for Background Image
  455.     if ($Config{'background'}) { print " background=\"$Config{'background'}\"" }
  456.  
  457.     # Check for Link Color
  458.     if ($Config{'link_color'}) { print " link=\"$Config{'link_color'}\"" }
  459.  
  460.     # Check for Visited Link Color
  461.     if ($Config{'vlink_color'}) { print " vlink=\"$Config{'vlink_color'}\"" }
  462.  
  463.     # Check for Active Link Color
  464.     if ($Config{'alink_color'}) { print " alink=\"$Config{'alink_color'}\"" }
  465.  
  466.     # Check for Body Text Color
  467.     if ($Config{'text_color'}) { print " text=\"$Config{'text_color'}\"" }
  468. }
  469.  
  470. sub error { 
  471.     # Localize variables and assign subroutine input.                        #
  472.     local($error,@error_fields) = @_;
  473.     local($host,$missing_field,$missing_field_list);
  474.  
  475.     if ($error eq 'bad_referer') {
  476.         if ($ENV{'HTTP_REFERER'} =~ m|^https?://([\w\.]+)|i) {
  477.             $host = $1;
  478.             print <<"(END ERROR HTML)";
  479. Content-type: text/html
  480.  
  481. <html>
  482.  <head>
  483.   <title>Bad Referrer - Access Denied</title>
  484.  </head>
  485.  <body bgcolor=#FFFFFF text=#000000>
  486.   <center>
  487.    <table border=0 width=600 bgcolor=#9C9C9C>
  488.     <tr><th><font size=+2>Bad Referrer - Access Denied</font></th></tr>
  489.    </table>
  490.    <table border=0 width=600 bgcolor=#CFCFCF>
  491.     <tr><td>The form attempting to use
  492.      <a href="http://www.worldwidemart.com/scripts/formmail.shtml">FormMail</a>
  493.      resides at <tt>$ENV{'HTTP_REFERER'}</tt>, which is not allowed to access
  494.      this cgi script.<p>
  495.  
  496.      If you are attempting to configure FormMail to run with this form, you need
  497.      to add the following to \@referers, explained in detail in the README file.<p>
  498.  
  499.      Add <tt>'$host'</tt> to your <tt><b>\@referers</b></tt> array.<hr size=1>
  500.      <center><font size=-1>
  501.       <a href="http://www.worldwidemart.com/scripts/formmail.shtml">FormMail</a> V1.6 © 1995 - 1997  Matt Wright<br>
  502.       A Free Product of <a href="http://www.worldwidemart.com/scripts/">Matt's Script Archive, Inc.</a>
  503.      </font></center>
  504.     </td></tr>
  505.    </table>
  506.   </center>
  507.  </body>
  508. </html>
  509. (END ERROR HTML)
  510.         }
  511.         else {
  512.             print <<"(END ERROR HTML)";
  513. Content-type: text/html
  514.  
  515. <html>
  516.  <head>
  517.   <title>FormMail v1.6</title>
  518.  </head>
  519.  <body bgcolor=#FFFFFF text=#000000>
  520.   <center>
  521.    <table border=0 width=600 bgcolor=#9C9C9C>
  522.     <tr><th><font size=+2>FormMail</font></th></tr>
  523.    </table>
  524.    <table border=0 width=600 bgcolor=#CFCFCF>
  525.     <tr><th><tt><font size=+1>Copyright 1995 - 1997 Matt Wright<br>
  526.         Version 1.6 - Released May 02, 1997<br>
  527.         A Free Product of <a href="http://www.worldwidemart.com/scripts/">Matt's Script Archive,
  528.         Inc.</a></font></tt></th></tr>
  529.    </table>
  530.   </center>
  531.  </body>
  532. </html>
  533. (END ERROR HTML)
  534.         }
  535.     }
  536.  
  537.     elsif ($error eq 'request_method') {
  538.             print <<"(END ERROR HTML)";
  539. Content-type: text/html
  540.  
  541. <html>
  542.  <head>
  543.   <title>Error: Request Method</title>
  544.  </head>
  545.  <body bgcolor=#FFFFFF text=#000000>
  546.   <center>
  547.    <table border=0 width=600 bgcolor=#9C9C9C>
  548.     <tr><th><font size=+2>Error: Request Method</font></th></tr>
  549.    </table>
  550.    <table border=0 width=600 bgcolor=#CFCFCF>
  551.     <tr><td>The Request Method of the Form you submitted did not match
  552.      either <tt>GET</tt> or <tt>POST</tt>.  Please check the form and make sure the
  553.      <tt>method=</tt> statement is in upper case and matches <tt>GET</tt> or <tt>POST</tt>.<p>
  554.  
  555.      <center><font size=-1>
  556.       <a href="http://www.worldwidemart.com/scripts/formmail.shtml">FormMail</a> V1.6 © 1995 - 1997  Matt Wright<br>
  557.       A Free Product of <a href="http://www.worldwidemart.com/scripts/">Matt's Script Archive, Inc.</a>
  558.      </font></center>
  559.     </td></tr>
  560.    </table>
  561.   </center>
  562.  </body>
  563. </html>
  564. (END ERROR HTML)
  565.     }
  566.  
  567.     elsif ($error eq 'no_recipient') {
  568.             print <<"(END ERROR HTML)";
  569. Content-type: text/html
  570.  
  571. <html>
  572.  <head>
  573.   <title>Error: No Recipient</title>
  574.  </head>
  575.  <body bgcolor=#FFFFFF text=#000000>
  576.   <center>
  577.    <table border=0 width=600 bgcolor=#9C9C9C>
  578.     <tr><th><font size=+2>Error: No Recipient</font></th></tr>
  579.    </table>
  580.    <table border=0 width=600 bgcolor=#CFCFCF>
  581.     <tr><td>No Recipient was specified in the data sent to FormMail.  Please
  582.      make sure you have filled in the 'recipient' form field with an e-mail
  583.      address.  More information on filling in recipient form fields can be
  584.      found in the README file.<hr size=1>
  585.  
  586.      <center><font size=-1>
  587.       <a href="http://www.worldwidemart.com/scripts/formmail.shtml">FormMail</a> V1.6 © 1995 - 1997  Matt Wright<br>
  588.       A Free Product of <a href="http://www.worldwidemart.com/scripts/">Matt's Script Archive, Inc.</a>
  589.      </font></center>
  590.     </td></tr>
  591.    </table>
  592.   </center>
  593.  </body>
  594. </html>
  595. (END ERROR HTML)
  596.     }
  597.  
  598.     elsif ($error eq 'missing_fields') {
  599.         if ($Config{'missing_fields_redirect'}) {
  600.             print "Location: $Config{'missing_fields_redirect'}\n\n";
  601.         }
  602.         else {
  603.             foreach $missing_field (@error_fields) {
  604.                 $missing_field_list .= "      <li>$missing_field\n";
  605.             }
  606.  
  607.             print <<"(END ERROR HTML)";
  608. Content-type: text/html
  609.  
  610. <html>
  611.  <head>
  612.   <title>Error: Blank Fields</title>
  613.  </head>
  614.   <center>
  615.    <table border=0 width=600 bgcolor=#9C9C9C>
  616.     <tr><th><font size=+2>Error: Blank Fields</font></th></tr>
  617.    </table>
  618.    <table border=0 width=600 bgcolor=#CFCFCF>
  619.     <tr><td>The following fields were left blank in your submission form:<p>
  620.      <ul>
  621. $missing_field_list
  622.      </ul><br>
  623.  
  624.      These fields must be filled in before you can successfully submit the form.<p>
  625.      Please use your browser's back button to return to the form and try again.<hr size=1>
  626.      <center><font size=-1>
  627.       <a href="http://www.worldwidemart.com/scripts/formmail.shtml">FormMail</a> V1.6 © 1995 - 1997  Matt Wright<br>
  628.       A Free Product of <a href="http://www.scriptarchive.com">Matt's Script Archive, Inc.</a>
  629.      </font></center>
  630.     </td></tr>
  631.    </table>
  632.   </center>
  633.  </body>
  634. </html>
  635. (END ERROR HTML)
  636.         }
  637.     }
  638.     exit;
  639. }
  640.  
  641.  
  642.